#include <bits/stdc++.h>
// 2025/02/01
// tag: 
// Author: Zhang Muen
using namespace std;

const int maxn = 100005;

int64_t n, m, diff[maxn], a[maxn], b[maxn], c[maxn];

void add(int l, int r, int k){
    diff[l] += k;
    diff[r + 1] -= k;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    int last = 0;
    cin >> last;
    for (int i = 2; i <= m; i++){
        int x;
        cin >> x;
        if (x > last)
            add(last, x - 1, 1);
        else
            add(x, last - 1, 1);
        last = x;
    }
    for (int i = 1; i < n; i++) 
        diff[i] += diff[i - 1];
    int64_t ans = 0;
    for (int i = 1; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
        ans += min(a[i] * diff[i], b[i] * diff[i] + c[i]);
    }
    cout << ans;
    return 0;
}